package com.itheima.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * <h1>分页基础对象</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @since 2022/11/1
 */
@Data
@ApiModel("查询参数对象")
public abstract class BasePageParam implements Serializable {
    private static final long serialVersionUID = -3263921252635611410L;
    @ApiModelProperty(
            value = "页码,默认为1",
            example = "1"
    )
    private Integer pageIndex;
    @ApiModelProperty(
            value = "页大小,默认为10",
            example = "10"
    )
    private Integer pageSize;
    @ApiModelProperty(
            value = "搜索字符串",
            example = ""
    )
    private String keyword;

    public void setPageIndex(Integer pageIndex) {
        if (pageIndex != null && pageIndex > 0) {
            this.pageIndex = pageIndex;
        } else {
            this.pageIndex = 1;
        }
    }

    public void setPageSize(Integer pageSize) {
        if (pageSize != null && pageSize > 0) {
            this.pageSize = pageSize;
        } else {
            this.pageSize =10;
        }

    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public String getKeyword() {
        return keyword;
    }

    public BasePageParam() {
        this.pageIndex = 1;
        this.pageSize = 10;
    }

}